#include <stdio.h>
#include <string.h>

#define MAX_SIZE 22  


int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

typedef struct {
    int x, y;   
    int step;    
    int pre;      
} Node;

Node queue[MAX_SIZE * MAX_SIZE];  
int maze[MAX_SIZE][MAX_SIZE];     
int visited[MAX_SIZE][MAX_SIZE];  
int path[MAX_SIZE * MAX_SIZE];   

void bfs(int n, int xs, int ys, int xe, int ye) {
    int front = 0, rear = 0;
    queue[rear++] = (Node){xs, ys, 0, -1};  
    visited[xs][ys] = 1;

    while (front < rear) {
        Node cur = queue[front];
        
     
        if (cur.x == xe && cur.y == ye) {
            printf("%d\n", cur.step);  
            
            int idx = front, cnt = 0;
            while (idx != -1) {
                path[cnt++] = idx;
                idx = queue[idx].pre;
            }
            
       
            for (int i = cnt-1; i >= 0; i--) {
                printf("(%d,%d)", queue[path[i]].x, queue[path[i]].y);
            }
            return;
        }


        for (int i = 0; i < 4; i++) {
            int nx = cur.x + dx[i];
            int ny = cur.y + dy[i];

            if (nx >= 1 && nx <= n && ny >= 1 && ny <= n 
                && !visited[nx][ny] && maze[nx][ny] == 0) {
                visited[nx][ny] = 1;
                queue[rear] = (Node){nx, ny, cur.step+1, front};
                rear++;
            }
        }
        front++;
    }
}

int main() {
    int n, xs, ys, xe, ye;
    scanf("%d%d%d%d%d", &n, &xs, &ys, &xe, &ye);
    

    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            scanf("%d", &maze[i][j]);
    
    bfs(n, xs, ys, xe, ye);
    return 0;
}
